package com.knoya.chejian.pda.module.packageTurnover

import android.content.Context
import android.util.Log
import com.knoya.chejian.pda.contacts.Contacts
import com.knoya.chejian.pda.minterface.OnUserDataInterface
import com.knoya.chejian.pda.module.chuku.ChukuPcodeBean
import com.knoya.chejian.pda.util.HttpUtil
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
import org.xutils.http.RequestParams
import org.xutils.x

class PackageTurnoverM {

    fun getdata(context : Context, pcode : String, onuserdatainterface : OnUserDataInterface){
        val params = RequestParams(Contacts.PACKAGE_TURNOVER)
        HttpUtil.getparams(context, params)
        params.addBodyParameter("pcode", pcode)

        x.http().get<String>(params, HttpUtil.Call(context, onuserdatainterface))
    }

    fun package_turnover(context : Context, mlist: List<PackageTurnoverBean>, onuserdatainterface : OnUserDataInterface){
        Log.d("TAAG", "ex=xxxxxxxxxxxxxxxxxxxxxx" + mlist)
        val params = RequestParams(Contacts.GO_PACKAGE_TURNOVER)
        HttpUtil.getparams(context, params)
        HttpUtil.addtoken(params)
        for (i in mlist.indices){
            params.addBodyParameter("pcodes[$i]",mlist[i].pcode.trim(),Contacts.BOUNDARY)
        }
        params.addBodyParameter("","",Contacts.BOUNDARY)
        x.http().post<String>(params, HttpUtil.Call(context,onuserdatainterface))
    }
}